﻿using Medianamik.Core.Sugar;
using NUnit.Framework;

namespace Medianamik.Tests.Unit.Medianamik.Core.Sugar
{
    [TestFixture]
    public class UrlAmpersandEncoderTest
    {
        private static readonly string _sampleEncodedUrl = @"http://www.absolunet.com/sections/index.html?param1=123456&amp;param2=&eacute;l&eacute;phant";
        private static readonly string _sampleRawUrl = @"http://www.absolunet.com/sections/index.html?param1=123456&param2=&eacute;l&eacute;phant";

        [SetUp]
        public void Init()
        {
            
        }

        [Test]
        public void UrlAmpersandEncoder_should_encode_ampersands()
        {
            string original = "http://www.absolunet.com/sections/index.html?p1=1&p2=a";
            string expected = "http://www.absolunet.com/sections/index.html?p1=1&amp;p2=a";
            
            string encoded = UrlAmpersandEncoder.Encode(original);

            Assert.That(encoded, Is.EqualTo(expected));
        }

        [Test]
        public void UrlAmpersandEncoder_should_not_encode_ampersands_in_htmlentities()
        {
            string original = "http://www.absolunet.com/sections/index.html?p1=1&amp;p2=&acute;&copy;";
            string expected = original;

            string encoded = UrlAmpersandEncoder.Encode(original);

            Assert.That(encoded, Is.EqualTo(expected));
        }

       
    }
}